package com.smart.fourteen.hibernate.annotate;

import com.smart.fourteen.hibernate.annotate.dao.TopicDao;
import com.smart.fourteen.hibernate.annotate.model.Topic;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class TestSpring {
    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("com/smart/fourteen/hibernate/annotate/applicationContext-spring-hibernate.xml");
        TopicDao topicDao = (TopicDao)ac.getBean("topicDao");
        System.out.println(topicDao);
        Topic topic = new Topic();
        topic.setName("a");

        topicDao.addTopic(topic);

        Topic getTopic = topicDao.getTopic(1);
        System.out.println(getTopic);

        List<Topic> topics = topicDao.findTopicByName("a");
        System.out.println(topics);

        long num = topicDao.getTopicNum();
        System.out.println(num);
    }
}
